Encryption functions
This section describes PKCS#11 encryption functions.
C_EncryptInit
This function operates as specified in PKCS#11.
The session will retain its initialized state even when a C_Encrypt or C_EncryptFinal operation has occurred.
If the CKF_LOGIN_REQUIRED
flag is set for the Token associated with the provided session the session state must be either CKS_RW_USER_FUNCTIONS
, or CKS_RO_USER_FUNCTIONS
otherwise the error result CKR_USER_NOT_LOGGED_IN
is returned.
If the hKey parameter refers to a certificate object this function will perform the same certificate verification as specified in the C_VerifyInit
function.
If the object referenced by the hKey parameter has the CKA_USAGE_COUNT
attribute its value is incremented by this function
Synopsis
C_EncryptInit(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey
);
C_Encrypt
This function operates as specified in PKCS#11 except for the following:
-
Symmetric cipher operations are terminated by this function.
-
C_Encrypt can be used to terminate a multi-part operation.
Although this function will terminate the current encryption operation, the session’s encryption state will not be cleared.
Note
If the mechanism in use is a multi-part mechanism and the data supplied exceeds a single block, that portion of the data is processed regardless of the result returned by the call. For example if 12 bytes are passed to a DES ECB operation, 8 bytes are processed even though an error result (due to the padding requirements not being met) is returned.
Cryptoki specifies that a successful return from one of these functions (when not used for length prediction) should result in the cipher state of that session being reset (to the uninitialized state). ProtectToolkit-C, however, leaves the state initialized so that another operation (using the same key) can be performed without calling the appropriate C_xxxInit function.
Synopsis
C_Encrypt(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pData,
CK_ULONG ulDataLen,
CK_BYTE_PTR pEncryptedData,
CK_ULONG_PTR pulEncryptedDataLen
);
C_EncryptUpdate
This function operates as specified in PKCS#11.
Synopsis
C_EncryptUpdate(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pPart,
CK_ULONG ulPartLen,
CK_BYTE_PTR pEncryptedPart,
CK_ULONG_PTR pulEncryptedPartLen
);
C_EncryptFinal
This function operates as specified in PKCS#11.
Although this function will terminate the current encryption operation the session’s encryption state will not be cleared.
Cryptoki specifies that a successful return from one of these functions (when not used for length prediction) should result in the cipher state of that session being reset (to the uninitialized state). ProtectToolkit-C, however, leaves the state initialized so that another operation (using the same key) can be performed without calling the appropriate C_xxxInit function.
Synopsis
C_EncryptFinal(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pLastEncryptedPart,
CK_ULONG_PTR pulLastEncryptedPartLen
);